<?php
############## DIT STUK CODE ZORGT ERVOOR DAT JE ALS ADMIN INGELOGD MOET ZIJN OM DE PAGINA TE KUNNEN ZIEN ##############
    //Start de sessie
    session_start();

    //Load de benodigde bestanden
    require_once("includes/auth.php");
########################################################################################################################
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Aanbieding instellen</title>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <link type="text/css" href="../css/pagination.css" rel="stylesheet" />
  <link rel="stylesheet" href="../css/reset.css" type="text/css" />
  <link rel="stylesheet" href="../css/960.css" type="text/css" />
  <link rel="stylesheet" href="../css/text.css" type="text/css" />
  <link type="text/css" href="../css/tablesorter.css" rel="stylesheet" />
  <link type="text/css" href="../css/sunny/jquery-ui-1.8.custom.css" rel="stylesheet" />
  <link type="text/css" href="../css/jquery.autocomplete.css" rel="stylesheet" />
  <link type="text/css" href="../css/style.css" rel="stylesheet" />
  <link type="text/css" href="../css/accmenu.css" rel="stylesheet" />
<script type="text/javascript" src="../js/jquery-1.4.2.min.js">
</script>
<script type="text/javascript" src="../js/jquery-ui-1.8.custom.min.js">
</script>
<script type="text/javascript" src="../js/jquery.tablesorter.js">
</script>
<script type="text/javascript" src="../js/jquery.autocomplete.min.js">
</script>
<script type="text/javascript" src="../js/menu.js">
</script>
<script type="text/javascript">
//<![CDATA[
$(document).ready(function()
    {
        $("#producttable").tablesorter();
    }
);
//]]>
</script>

</head>

<body>
  <div class="container_12">
    <div id="header" class="grid_12">

    </div>

    <div class="clear"></div>

    <div class="grid_12 spacer"></div>

    <div class="clear"></div>

    <div id="menu" class="grid_2">

        <?php
        include_once 'temp/menu_filler.php';
        ?>


    </div>

    <div id="adminarea" class="grid_10">
        <div id="tableholder">

              <?php

              // Connects to your Database
              include 'includes/connect.php';


              
              
              
                  	if(isset($_GET['id']) && is_numeric($_GET['id']))
                  	{
                  		// Geef de variabele $id de waarde van de id= parameter uit de URL mee
                  		$id=$_GET['id'];


                  	}
                  	else
                  	{
                  		// Stop script als id niet numeriek is
                  		die("<b>Error:</b> Hacking attempt!!! ");
                  	}

                  	// Retrieve all the data from the table
                  	
                  	$query = "SELECT * FROM product WHERE productid=" . $id . " ";
                  	// echo 'query is: ',$query;
                  	$result = mysql_query($query) or die("the query returned an error: " . mysql_error());

                  	while ($row = mysql_fetch_array($result)) {
                  		$pid = $row['productid'];
                  		$pnm = $row['productnaam'];
                  		$std = $row['stdprijs'];

                        if($row['Promotieprijs'] !== '0')
                        {
                      		$pro = $row['Promotieprijs'];
                        }

                        if($row['begindate'] !== '0')
                        {
                            $bd = date("d",$row['begindate']);
                            $bm = date("m",$row['begindate']);
                            $by = date("Y",$row['begindate']);
                        }

                        if($row['enddate'] !== '0')
                        {
                            $ed = date("d",$row['enddate']);
                            $em = date("m",$row['enddate']);
                            $ey = date("Y",$row['enddate']);
                        }

                  }

                  ?>
              <form enctype="multipart/form-data"  action="prom2_prod.php?id=<?php echo $id; ?>" method="POST">
              ProductID: <?php echo $id ?> <input type= "hidden" name= "productid" value="<?php echo $id ?>" /> <br />
              Productnaam: <?php echo $pnm ?> <input type="hidden" name="productnaam" value="<?php echo $pnm ?>" /><br />
              Normale Prijs: <?php echo "&euro;".number_format($std,2); ?> <input type="hidden" name="stdprijs" value="<?php echo $std ?>" /><br />
              Promotie Prijs: &euro;<input type="text" name="promotieprijs" value="<?php echo $pro ?>" size="6" /><br />
              Begin datum:  Dag  <input type="text" name="b_dag" value="<?php echo $bd ?>" size="2"/>  Maand:<input type="text" name="b_maand" value="<?php echo $bm ?>" size="2"/>  Jaar:<input type="text" name="b_jaar" value="<?php echo $by ?>" size="4"/><br />
              Eind datum:&nbsp;&nbsp;&nbsp;Dag  <input type="text" name="e_dag" value="<?php echo $ed ?>" size="2"/>  Maand:<input type="text" name="e_maand" value="<?php echo $em ?>" size="2" />  Jaar:<input type="text" name="e_jaar" value="<?php echo $ey ?>" size = "4"/><br />
              <input type="submit" />
              </form>
              

</div>
    </div>


    <div class="clear"></div>

    <div class="grid_12 spacer"></div>

    <div class="clear"></div>
</div>
</body>
</html>